/** 管理模块 和 商户系统，用到的js **/
function k_pop_goodsprice(url_,goods_id,title_){
		k_loading('');
		//alert($('#goods_id').val());
		$.ajax({      
						url:url_,      
						type:'post',  
						data:{goods_id:goods_id} ,        
						error:function(json){     
								k_alert( 'not lived!');     
						},     
						async: false ,   
						success: function(txt){  
								if(txt==null||txt==''){k_alert('无相应价格信息！','提示');return;}
								var objs	=	eval('(' + txt + ')');
								html_ = '<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
												'<tr>'+
												'<th class="" style="width:90px;padding:5px;text-align:center;">开始时间</td>'+
				    						'<th class="line_l" style="width:90px;padding: 5px;text-align:center;">截止时间</td>'+
				    						'<th class="line_l" style="width:70px;padding: 5px;text-align:center;">市场价</td>'+
				    						'<th class="line_l" style="width:70px;padding: 5px;text-align:center;">进货价</td>'+
				    						'<th class="line_l" style="width:70px;padding: 5px;text-align:center;">进货量</td>'+
				    						'<th class="line_l" style="width:70px;padding: 5px;text-align:center;">送出量</td>'+
				    						'<th class="line_l" style="width:50px;padding: 5px;text-align:center;">是否有效</td>'+
												'</tr>';
				    		for(i=0;i<objs.length;i++){
				    				html_ = html_+
				    								'<tr onclick="'+
				    								'$(\'#market_price\').val(\''+objs[i].market_price+'\');'+
				    								'$(\'#total_number\').val(\''+objs[i].total_number+'\');'+
				    								'ui.box.close();'+
				    								'"><td style="padding: 5px;text-align:center;">'+objs[i].start_time+'</td>'+
				    								'<td style="padding: 5px;text-align:center;">'+objs[i].expire_time+'</td>'+
				    								'<td style="padding: 5px;text-align:right;">'+objs[i].market_price+'</td>'+
				    								'<td style="padding: 5px;text-align:right;">'+objs[i].in_price+'</td>'+
				    								'<td style="padding: 5px;text-align:right;">'+objs[i].total_number+'</td>'+
				    								'<td style="padding: 5px;text-align:right;">'+objs[i].send_number+'</td>'+
				    								'<td style="padding: 5px;text-align:center;">'+objs[i].enable+'</td>'+
														'</tr>';
				    		}
				    		html_ = html_+'</table>';
								//$('$market_price').val(obj.market_price);
								//$('$total_number').val(obj.total_number);
								context =	'<div id="k_confirm_div" class="pop_form alL" style="width:600px;">'+
														'<div class="c"></div>'+
												    '<div class="pop_form_li">'+
												    		'<div class="list" style="margin:15px">'+
												        	html_+
												    		'</div>'+
												    '</div>'+
												    '<div class="c"></div>'+
													'</div>';
								ui.box.show(context,{title:title_});
						}     
		});
}

var pop_syncSearch_option;
var pop_syncSearch_callback_ok;
var pop_syncSearch_callback_cancel;
/**通过录入数据动态查询，结果弹出框。并对结果做相应处理**/
function k_pop_syncSearch(html_id,html_name_id,title_,url,callback_ok,callback_cancel){
		pop_syncSearch_option = new Array(html_id,html_name_id,url);
		pop_syncSearch_callback_ok = callback_ok;
		pop_syncSearch_callback_cancel = callback_cancel;
		var context='<div id="k_confirm_div" class="pop_form alL" style="width:300px;">'+
							'<div class="c"></div>'+
					    '<div class="pop_form_li">'+
					    		'<div style="text-align: left; margin:10px 20px">'+
					        '搜索：<input name="syncsearch_text" style="width:210px" class="normal_input" id="syncsearch_text" type="text" onkeyup="k_pop_syncSearch_getjson()" value="' + $('#'+pop_syncSearch_option[1]).val() + '" >'+
					    		'</div>'+
					    		'<div style="margin:0px 20px 5px">点击选择：</div>'+
					    		'<div id="show_syncsearch_result" style="margin:0px 20px 10px 30px;line-height: 20px;"></div>'+
					    '</div>'+
					    '<div class="c"></div>'+
					    '<div class="answers">'+
					    	'<input type="button" id="k_confirm_btn" value="清空" onclick="k_pop_syncSearch_cancel()" class="btn_cancel" />'+
					    '</div>'+
						'</div>';
		ui.box.show(context,{title:title_});
		k_pop_syncSearch_getjson();
}
/**通过录入数据随时加载数据函数*/
function k_pop_syncSearch_getjson(){
		//alert(pop_syncSearch_option[0]+" "+pop_syncSearch_option[1]+" "+pop_syncSearch_option[2]);
		var syncsearch_text = $('#k_confirm_div').find('#syncsearch_text').val();
		$.ajax({      
		    url:pop_syncSearch_option[2],      
		    type:'post', //数据发送方式  
		    data:{searchtext:syncsearch_text} ,   
		    //dataType:'xml', //接受数据格式      
		    error:function(json){     
		            // alert( "not lived!");     
		       },     
		    async: false ,//同步方式     
		    success: function(txt){ 
		    		//alert(txt); 
		    		var objs	=	eval('(' + txt + ')');
		    		var html_ = '';
		    		for(i=0;i<objs.length;i++){
		    				html_ = html_+'<a style="margin-top:3px;height: auto;" href="javascript:k_pop_syncSearch_ok(\''+objs[i].id+'\',\''+objs[i].title+'\')">'+
		    								objs[i].title+'</a><br>';
		    		}
		    		$('#k_confirm_div').find('#show_syncsearch_result').html(html_);
		    }     
  	});   
		
}
/**点击选择后处理函数*/
function k_pop_syncSearch_ok(selected_id,selected_desc){
		
		$('#'+pop_syncSearch_option[0]).val(selected_id);
		$('#'+pop_syncSearch_option[1]).val(selected_desc);
		
		if(pop_syncSearch_callback_ok!=null)pop_syncSearch_callback_ok();
		else ui.box.close();
}
/**点击清空后处理函数*/ 
function k_pop_syncSearch_cancel(){
		$('#'+pop_syncSearch_option[0]).val('');
		$('#'+pop_syncSearch_option[1]).val('');
		
		if(pop_syncSearch_callback_cancel!=null)pop_syncSearch_callback_cancel();
		ui.box.close();
}